<extend name="default/template/base_scoreshop" />

<block name="head">
    <link rel="stylesheet" href="__CSS__/scoreshop_exlog.css?v=" />
</block>

<block name="body">
<volist name="list" id="vo">
<div class="record-list">
  <a href="{:U('Webview/ExchangeLog/detail',array('uid'=>$uid,'psw'=>$psw,'id'=>$vo['id']))}">
  <div class="record">
    <p>{$vo.exchange_time}</p>
    <div class="record-img"><img src="{:getImageUrl($vo['main_img'],0,1)}"></div>
    <ul>
      <li><span class="first-msg">{$vo.brand}</span></li>
      <li><span class="second-msg">{$vo.pname}</span></li>
      <li><span class="money">{$vo.score|intval}</span><span class="third-msg">萌币<if condition="$vo.price gt 0">+</if></span><if condition="$vo.price gt 0"><span class="money">￥{$vo.price}</span></if>
        <!-- <span class="fourth-msg">x1</span> --></li>
    </ul>
    <span class="express">{$vo.exchange_status}</span>
  </div>
  </a>
</div>
</volist>
<!-- message -->
<center class="message hide" id="my-alert"></center>
<!-- message end -->
<script>
function myalert(con,ele){
  // $('body').addClass('fade');
  if(!ele) ele='my-alert';
  $ele = $('#'+ele);
  if(!con) return;//con='此地无银';
  $ele.html('<div>'+con+'</div>').show();
  setTimeout(function(){
    $ele.hide();
  },500)
}
$(function() {
  var progress = $.AMUI.progress;
  $('.am-modal-btn').click(function(){
    $('body').removeClass('fade');
    $('.am-modal').removeClass('am-modal-active');
  });

  var $window = $(window);
  $.ajaxSettings.async = false;
  var wh = $window.innerHeight(),sh,url = '{$ajaxurl}',f = true,p=1;
  $window.scroll(function(){
    sh = getScrollHeight();
    if(f && (sh>wh-50)){
      f = !f;
      progress.start();
      // console.log('in');
      $.getJSON(url,{
        start:p*10,
        size:10,
      },function(data){
        html = '';
        progress.done();
        if(!data.status){
          myalert(data.info);
          return;
        }
        info = data.info;
        var len = info.length;
        if(!len){
          myalert('没有更多了');
          $window.scroll(function(){ });
          return;
        }else{
          for (var i =0;i< len; i++) {
            item = info[i];
            html += '<div class="record-list">'+
  '<a href="'+item.url+'">'+
  '<div class="record">'+
    '<p>'+item.exchange_time+'</p>'+
    '<div class="record-img"><img src="'+item.main_img+'"></div>'+
    '<ul>'+
      '<li><span class="first-msg">'+item.brand+'</span></li>'+
      '<li><span class="second-msg">'+item.pname+'</span></li>'+
      '<li><span class="money">'+parseInt(item.score)+'</span><span class="third-msg">萌币'+((item.price>0)?'+':'')+'</span>'+((item.price>0)?'<span class="money">￥ '+item.price+'</span>':'')+
        '</li>'+
    '</ul>'+
    '<span class="express">'+item.exchange_status+'</span>'+
  '</div>'+
  '</a>'+
'</div>';
          };
          $('body').append(html);
          p++;
          f=!f;
          // console.log('data');
          // console.log(data);
          // console.log('html');
          // console.log(html);
        }
      });
    }
  });

  function getScrollHeight(){
    return document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
  }
});
</script>
</block>